function loadGridData(obj,grid)

% This file is part of CISNE.
%
%     CISNE is free software: you can redistribute it and/or modify
%     it under the terms of the GNU General Public License as published by
%     the Free Software Foundation, either version 3 of the License, or
%     any later version.
%
%     CISNE is distributed in the hope that it will be useful,
%     but WITHOUT ANY WARRANTY; without even the implied warranty of
%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%     GNU General Public License for more details.
%
%     You should have received a copy of the GNU General Public License
%     along with CISNE.  If not, see <http://www.gnu.org/licenses/>.

% Copyright 2011. Jose Maria Garcia-Valdecasas Bernal

data=obj.m_grids.(grid);

%borramos las propiedades anteriores y creamos la nueva lista
obj.m_gridList.clear();
for j=1:size(data,1)
    prop=com.jidesoft.grid.DefaultProperty();
    prop.setName(data{j,1});
    if strcmp(data{j,3},'num')
        prop.setType(obj.m_jnum);
    elseif strcmp(data{j,3},'file')
        prop.setType(obj.m_jstr);
        com.jidesoft.grid.CellEditorManager.registerEditor(obj.m_jstr,...
            com.jidesoft.grid.FileCellEditor,...
            com.jidesoft.grid.FileCellEditor.CONTEXT);
        prop.setEditorContext(com.jidesoft.grid.FileCellEditor.CONTEXT)
    elseif strcmp(data{j,3},'bool')
        prop.setType(obj.m_jbool);
        com.jidesoft.grid.CellEditorManager.registerEditor(obj.m_jbool,...
            com.jidesoft.grid.BooleanCheckBoxCellEditor,...
            com.jidesoft.grid.BooleanCheckBoxCellEditor.CONTEXT);
        prop.setEditorContext(com.jidesoft.grid.BooleanCheckBoxCellEditor.CONTEXT)
    elseif strcmp(data{j,3},'ftype')
        prop.setType(obj.m_jint);
        options = {1, 2, 3, 4, 5, 6};
        editor = com.jidesoft.grid.ListComboBoxCellEditor(options);
        context = getContext('combobox');
        com.jidesoft.grid.CellEditorManager.registerEditor(obj.m_jint, ...
            editor, context);
        prop.setEditorContext(context);
        
    
    elseif strcmp(data{j,3},'style')
        prop.setType(obj.m_jstr);
        options = {'image','contourlines'};
        editor = com.jidesoft.grid.ListComboBoxCellEditor(options);
        context = getContext('combobox');
        com.jidesoft.grid.CellEditorManager.registerEditor(obj.m_jstr, ...
            editor, context);
        prop.setEditorContext(context);
        
        
    elseif strcmp(data{j,3},'slide')
        prop.setType(obj.m_jint);
        
        %editor = com.jidesoft.grid.SliderCellEditor(int32(0),int32(100));
        %context = getContext('slider');
        %com.jidesoft.grid.CellEditorManager.registerEditor(obj.m_jint, ...
        %    editor, context);
        %prop.setEditorContext(context);
        
        
    end
    prop.setValue(data{j,4});
    prop.setDisplayName(data{j,1});
    prop.setDescription(data{j,2});
    prop.setEditable(true);
    obj.m_gridList.add(prop);
end
obj.m_gridmodel.refresh();
obj.m_gridmodel.expandAll();
obj.m_gridmodel.refresh();

function Context=getContext(editorType)
persistent ContextCounter;
if isempty(ContextCounter)  % if not yet assigned
   ContextCounter = 1;
end

Context = com.jidesoft.grid.EditorContext(['JIDE_' editorType '_' int2str(ContextCounter)]);

ContextCounter = ContextCounter+1;